import subprocess

def git_commit_push(message):
    try:
        # 添加所有更改到暂存区
        subprocess.run(['git', 'add', '.'], check=True)
        
        # 提交更改
        subprocess.run(['git', 'commit', '-m', message], check=True)
        
        # 推送到远程仓库的 master 分支
        subprocess.run(['git', 'push', 'origin', 'master'], check=True)
        
        print("Git operations completed successfully.")
    except subprocess.CalledProcessError as e:
        print(f"An error occurred: {e}")

# 使用方法
if __name__ == "__main__":
    message = input("Enter your commit message: ")
    git_commit_push(message)